/*
 * pruebaGestionColecciones.java
 *
 * Created on 7 de enero de 2006, 16:04
 */

package fmap.gui;

import fmap.DatosCompartidos;
import fmap.gui.actionListener.ListenerJFrameAdminCollection;
import fmap.utils.FormUtils;
import javax.swing.JButton;
import javax.swing.JLabel;

/**
 *
 * @author  javi
 */
public class JFrameAdminCollection extends javax.swing.JFrame
{
    /** Creates new form pruebaGestionColecciones */
    public JFrameAdminCollection ()
    {
        ListenerJFrameAdminCollection listener = new ListenerJFrameAdminCollection ();
        
        /**
         * Obtenemos un array de colecciones
         * Inicializamos la lista con el array de colecciones
         */
        fmap.model.Collection[] aCol = (fmap.model.Collection[])new fmap.actions.collection.GetCollectionsAction ().GetCollectionsAction ();
        
        initComponents ();
        
        if ( aCol != null ) listCollections.setListData ( aCol );
        listCollections.addListSelectionListener ( listener );
        
        buttonOpenCollection.addActionListener ( listener );
        buttonDeleteCollection.addActionListener ( listener );
        buttonSaveCollection.addActionListener ( listener );
        buttonNewCollection.addActionListener ( listener );
        buttonCancelNewCollection.addActionListener ( listener );
        buttonCloseColletion.addActionListener ( listener );
        buttonEditCollection.addActionListener ( listener );

        java.awt.CardLayout layout = (java.awt.CardLayout)panelContentCard.getLayout ();
        
        layout.show (panelContentCard,"card2");
        
        FormUtils.centra (this);
        
        if( DatosCompartidos.getCollectionActual () != null )
        {
            labelCollectionOpen.setText ( DatosCompartidos.getCollectionActual ().getName () );
        }
        else
        {
            labelCollectionOpen.setText ( fmap.utils.IConstants.MSJ_COLECCION_NO_ABIERTA );
            buttonCloseColletion.setEnabled ( false );
        }
        
        this.setVisible ( true );
    }
    
    public JButton getButtonClose ()
    { return buttonCloseColletion; }
    public JLabel getLabelCollectionOpen ()
    { return labelCollectionOpen; }
    public javax.swing.JTextField getTextFNewCollection ()
    { return textFNewCollection; }
    public javax.swing.JTextArea getTxtFComentNewCollection ()
    { return txtFComentNewCollection; }
    public javax.swing.JList getListCollection ()
    { return listCollections; }
    public javax.swing.JPanel getPanel3 ()
    { return panelContentCard; }
    
    /**
     * Inicia todos los componentes gr�ficos de este JFrame
     */
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
    private void initComponents()
    {
        jScrollPane2 = new javax.swing.JScrollPane();
        listCollections = new javax.swing.JList();
        buttonOpenCollection = new javax.swing.JButton();
        buttonDeleteCollection = new javax.swing.JButton();
        buttonNewCollection = new javax.swing.JButton();
        panelContentCard = new javax.swing.JPanel();
        jLayeredPane1 = new javax.swing.JLayeredPane();
        jLabel1 = new javax.swing.JLabel();
        textFNewCollection = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        txtFComentNewCollection = new javax.swing.JTextArea();
        buttonSaveCollection = new javax.swing.JButton();
        buttonCancelNewCollection = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jLayeredPane3 = new javax.swing.JLayeredPane();
        jLabel3 = new javax.swing.JLabel();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jLayeredPane2 = new javax.swing.JLayeredPane();
        buttonCloseColletion = new javax.swing.JButton();
        labelCollectionOpen = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        buttonEditCollection = new javax.swing.JButton();

        setTitle("Gesti\u00f3n Colecciones");
        setAlwaysOnTop(true);
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setResizable(false);
        jScrollPane2.setViewportView(listCollections);

        buttonOpenCollection.setText("Abrir");
        buttonOpenCollection.setActionCommand("jb_abrir");
        buttonOpenCollection.setName("");

        buttonDeleteCollection.setText("Eliminar");
        buttonDeleteCollection.setActionCommand("jb_eliminar");
        buttonDeleteCollection.setMaximumSize(new java.awt.Dimension(128, 25));
        buttonDeleteCollection.setMinimumSize(new java.awt.Dimension(128, 25));
        buttonDeleteCollection.setName("");
        buttonDeleteCollection.setPreferredSize(new java.awt.Dimension(128, 25));

        buttonNewCollection.setText("Crear coleccion");
        buttonNewCollection.setActionCommand("jb_nueva");
        buttonNewCollection.setName("");

        panelContentCard.setLayout(new java.awt.CardLayout());

        jLayeredPane1.setBackground(new java.awt.Color(255, 51, 51));
        jLayeredPane1.setBorder(javax.swing.BorderFactory.createTitledBorder("Nueva Colecci\u00f3n"));
        jLabel1.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel1.setText("Nombre");
        jLabel1.setBounds(30, 20, 47, 15);
        jLayeredPane1.add(jLabel1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        textFNewCollection.setBounds(130, 20, 340, 19);
        jLayeredPane1.add(textFNewCollection, javax.swing.JLayeredPane.DEFAULT_LAYER);

        txtFComentNewCollection.setColumns(20);
        txtFComentNewCollection.setRows(5);
        jScrollPane1.setViewportView(txtFComentNewCollection);

        jScrollPane1.setBounds(130, 50, 340, 40);
        jLayeredPane1.add(jScrollPane1, javax.swing.JLayeredPane.DEFAULT_LAYER);

        buttonSaveCollection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/save.png")));
        buttonSaveCollection.setText("Guardar");
        buttonSaveCollection.setActionCommand("jb_guardar");
        buttonSaveCollection.setMargin(new java.awt.Insets(3, 0, 3, 0));
        buttonSaveCollection.setName("");
        buttonSaveCollection.setPreferredSize(new java.awt.Dimension(80, 18));
        buttonSaveCollection.setBounds(372, 100, 100, 30);
        jLayeredPane1.add(buttonSaveCollection, javax.swing.JLayeredPane.DEFAULT_LAYER);

        buttonCancelNewCollection.setIcon(new javax.swing.ImageIcon(getClass().getResource("/fmap/img/no_disponible.png")));
        buttonCancelNewCollection.setText("Cancelar");
        buttonCancelNewCollection.setActionCommand("jb_cancelar");
        buttonCancelNewCollection.setMargin(new java.awt.Insets(2, 4, 2, 4));
        buttonCancelNewCollection.setMaximumSize(new java.awt.Dimension(84, 20));
        buttonCancelNewCollection.setMinimumSize(new java.awt.Dimension(84, 20));
        buttonCancelNewCollection.setName("");
        buttonCancelNewCollection.setPreferredSize(new java.awt.Dimension(84, 20));
        buttonCancelNewCollection.setBounds(250, 100, 100, 30);
        jLayeredPane1.add(buttonCancelNewCollection, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jLabel2.setFont(new java.awt.Font("Dialog", 0, 12));
        jLabel2.setText("Comentario");
        jLabel2.setBounds(30, 50, 66, 15);
        jLayeredPane1.add(jLabel2, javax.swing.JLayeredPane.DEFAULT_LAYER);

        panelContentCard.add(jLayeredPane1, "card3");

        jLayeredPane3.setBorder(javax.swing.BorderFactory.createTitledBorder("Abrir nueva colecci\u00f3n"));
        jLabel3.setText("\u00bfDesea abrir la nueva colecci\u00f3n?");
        jLabel3.setBounds(50, 40, 210, -1);
        jLayeredPane3.add(jLabel3, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton7.setText("SI");
        jButton7.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                jButton7ActionPerformed(evt);
            }
        });

        jButton7.setBounds(330, 40, 70, -1);
        jLayeredPane3.add(jButton7, javax.swing.JLayeredPane.DEFAULT_LAYER);

        jButton8.setText("NO");
        jButton8.addActionListener(new java.awt.event.ActionListener()
        {
            public void actionPerformed(java.awt.event.ActionEvent evt)
            {
                jButton8ActionPerformed(evt);
            }
        });

        jButton8.setBounds(330, 80, 70, -1);
        jLayeredPane3.add(jButton8, javax.swing.JLayeredPane.DEFAULT_LAYER);

        panelContentCard.add(jLayeredPane3, "card4");

        jLayeredPane2.setBorder(javax.swing.BorderFactory.createTitledBorder("Colecci\u00f3n abierta"));
        buttonCloseColletion.setText("Cerrar Coleccion");
        buttonCloseColletion.setActionCommand("buttonCerrar");
        buttonCloseColletion.setName("");
        buttonCloseColletion.setBounds(20, 60, 440, 70);
        jLayeredPane2.add(buttonCloseColletion, javax.swing.JLayeredPane.DEFAULT_LAYER);

        labelCollectionOpen.setFont(new java.awt.Font("Dialog", 0, 12));
        labelCollectionOpen.setForeground(java.awt.Color.blue);
        labelCollectionOpen.setBounds(20, 30, 440, 10);
        jLayeredPane2.add(labelCollectionOpen, javax.swing.JLayeredPane.DEFAULT_LAYER);

        panelContentCard.add(jLayeredPane2, "card2");

        jLabel5.setFont(new java.awt.Font("Dialog", 0, 11));
        jLabel5.setLabelFor(listCollections);
        jLabel5.setText("Colecciones");
        jLabel5.setVerticalAlignment(javax.swing.SwingConstants.BOTTOM);
        jLabel5.setMaximumSize(new java.awt.Dimension(65, 17));

        buttonEditCollection.setText("Editar");
        buttonEditCollection.setActionCommand("jb_editar");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(panelContentCard, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 494, Short.MAX_VALUE)
                    .add(layout.createSequentialGroup()
                        .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 327, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(19, 19, 19)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                            .add(buttonDeleteCollection, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                            .add(buttonNewCollection, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                            .add(buttonEditCollection, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE)
                            .add(buttonOpenCollection, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE))))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .add(4, 4, 4)
                .add(jLabel5, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 14, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                    .add(layout.createSequentialGroup()
                        .add(buttonOpenCollection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(14, 14, 14)
                        .add(buttonEditCollection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(14, 14, 14)
                        .add(buttonNewCollection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 34, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .add(14, 14, 14)
                        .add(buttonDeleteCollection, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 33, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(jScrollPane2))
                .add(39, 39, 39)
                .add(panelContentCard, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 149, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(13, Short.MAX_VALUE))
        );
        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton8ActionPerformed (java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton8ActionPerformed
    {//GEN-HEADEREND:event_jButton8ActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_jButton8ActionPerformed

    private void jButton7ActionPerformed (java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton7ActionPerformed
    {//GEN-HEADEREND:event_jButton7ActionPerformed
// TODO add your handling code here:
    }//GEN-LAST:event_jButton7ActionPerformed
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonCancelNewCollection;
    private javax.swing.JButton buttonCloseColletion;
    private javax.swing.JButton buttonDeleteCollection;
    private javax.swing.JButton buttonEditCollection;
    private javax.swing.JButton buttonNewCollection;
    private javax.swing.JButton buttonOpenCollection;
    private javax.swing.JButton buttonSaveCollection;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLayeredPane jLayeredPane1;
    private javax.swing.JLayeredPane jLayeredPane2;
    private javax.swing.JLayeredPane jLayeredPane3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel labelCollectionOpen;
    private javax.swing.JList listCollections;
    private javax.swing.JPanel panelContentCard;
    private javax.swing.JTextField textFNewCollection;
    private javax.swing.JTextArea txtFComentNewCollection;
    // End of variables declaration//GEN-END:variables
    
}
